package ArrayList;
import java.util.Scanner;
import java.util.ArrayList;

public class FoodOperator {
    private ArrayList<Food> foodList = new ArrayList<>();
    // 上架菜品功能
    private void addFood(){
        // 创建菜品对象，封装上架的菜品信息
        Food f = new Food();
        Scanner sc = new Scanner(System.in);

        // 录入菜品信息
        System.out.print("请输入当前菜品名称：");
        String name = sc.next();
        f.setName(name);

        System.out.print("请输入当前菜品价格：");
        double price = sc.nextDouble();
        f.setPrice(price);

        System.out.print("请输入当前菜品描述：");
        String dese = sc.next();
        f.setDese(dese);

        // 把菜品对象存入foodList中
        foodList.add(f);
        System.out.println("上架成功！");
    }

    // 展示菜品
    public void showAllFoods(){
        if(foodList.size() == 0){
            System.out.println("当前没有菜品。");
            return;
        }
        for(int i = 0;i < foodList.size();i++){
            Food f = foodList.get(i);
            System.out.println("菜品名称：" + f.getName());
            System.out.println("菜品价格：" + f.getPrice());
            System.out.println("菜品简介：" + f.getDese());
            System.out.println("-------------------------");
        }
    }
    // 展示操作界面
    public void start(){
        while(true){
            System.out.println("********************");
            System.out.println("1.添加菜品   2.展示菜品");
            System.out.println("0.退出系统");
            System.out.println("********************");
            Scanner sc = new Scanner(System.in);
            System.out.print("请选择功能：");
            String command = sc.next();
            switch(command){
                case "1":
                    addFood();
                    break;
                case "2":
                    showAllFoods();
                    break;
                case "0":
                    System.out.println("退出系统。");
                    return; // 退出方法
                default:
                    System.out.println("您输入的命令不存在。");
                    break;

            }
        }
    }
}